package com.hncc.sms.controller;

import java.util.List;

import com.hncc.sms.domain.SmsSkdRule;
import com.hncc.sms.domain.SmsSkdRuleItem;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.hncc.sms.service.ISmsSkdRuleService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import javax.annotation.Resource;

/**
 * 排班规则Controller
 * 
 * @author ruoyi
 * @date 2020-08-08
 */
@RestController
@RequestMapping("/sms/skd_rule")
@Api(tags = "排班规则接口")
public class SmsSkdRuleController extends BaseController
{
    @Resource
    private ISmsSkdRuleService smsSkdRuleService;

    /**
     * 查询排班规则列表
     */
    @ApiOperation(value = "条件分页查询排班规则",httpMethod = "GET")
    @PreAuthorize("@ss.hasPermi('sms:skd_rule:list')")
    @GetMapping("/list")
    public TableDataInfo list(SmsSkdRule smsSkdRule)
    {
        startPage();
        List<SmsSkdRule> list = smsSkdRuleService.selectSmsSkdRuleList(smsSkdRule);
        return getDataTable(list);
    }

    /**
     * 导出排班规则列表
     */
    @PreAuthorize("@ss.hasPermi('sms:skd_rule:export')")
    @Log(title = "排班规则", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(SmsSkdRule smsSkdRule)
    {
        List<SmsSkdRule> list = smsSkdRuleService.selectSmsSkdRuleList(smsSkdRule);
        ExcelUtil<SmsSkdRule> util = new ExcelUtil<SmsSkdRule>(SmsSkdRule.class);
        return util.exportExcel(list, "skd_rule");
    }

    /**
     * 获取排班规则详细信息
     */
    @ApiOperation(value = "根据id获取排班规则详细信息",httpMethod = "GET",
            notes = "根据id查询排班规则")
    @ApiImplicitParam(paramType = "path",name = "id",value = "排班规则id",dataType = "Long",required = true)
    @PreAuthorize("@ss.hasPermi('sms:skd_rule:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(smsSkdRuleService.selectSmsSkdRuleById(id));
    }

    /**
     * 新增排班规则
     */
    @ApiOperation(value = "新增",httpMethod = "POST", notes = "新增排班规则")
    @ApiImplicitParam(name = "smsSkdRule", value = "新增排班规则", dataType = "SmsSkdRule")
    @PreAuthorize("@ss.hasPermi('sms:skd_rule:add')")
    @Log(title = "排班规则", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SmsSkdRule smsSkdRule)
    {
        return toAjax(smsSkdRuleService.insertSmsSkdRule(smsSkdRule));
    }

    /**
     * 修改排班规则
     */
    @ApiOperation(value = "修改", httpMethod = "PUT", notes = "修改排班规则")
    @ApiImplicitParam(name = "smsSkdRule", value = "修改排班规则", dataType = "SmsSkdRule")
    @PreAuthorize("@ss.hasPermi('sms:skd_rule:edit')")
    @Log(title = "排班规则", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SmsSkdRule smsSkdRule)
    {
        return toAjax(smsSkdRuleService.updateSmsSkdRule(smsSkdRule));
    }

    /**
     * 删除排班规则
     */
    @ApiOperation(value = "批量删除", httpMethod = "DELETE", notes = "根据ids删除排班规则")
    @ApiImplicitParam(paramType = "path",name = "ids",value = "排班规则id",dataType = "Long[]",required = true)
    @PreAuthorize("@ss.hasPermi('sms:skd_rule:remove')")
    @Log(title = "排班规则", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(smsSkdRuleService.deleteSmsSkdRuleByIds(ids));
    }
}
